let Announcement = function() {
    this.id = 0;
    this.title = "";
    this.content = "";
    this.startTime = 0;
    this.endTime = 0;
};

Announcement.prototype.toBSON = function() {
    return {
        id : this.id,
        title : this.title,
        content : this.content,
        startTime : this.startTime,
        endTime : this.endTime,
    };
};

Announcement.prototype.toJSON = function () {
    return {
        id : this.id,
        title : this.title,
        content : this.content,
        startTime : this.startTime,
        endTime : this.endTime,
    };
};

module.exports.create = function(id, title, content, startTime, endTime) {
    let announcement = new Announcement();
    announcement.id = id;
    announcement.title = title;
    announcement.content = content;
    announcement.startTime = startTime;
    announcement.endTime = endTime;
    return announcement;
};

module.exports.loadFromDocument = function (document) {
    let announcement = new Announcement();
    announcement.id = document["id"];
    announcement.title = document["title"];
    announcement.content = document["content"];
    announcement.startTime = document["startTime"];
    announcement.endTime = document["endTime"];
    return announcement;
};
